package com.ctrip.ec.biz.dao.app;
import com.ctrip.ec.dal.DaoBase;
import com.ctrip.ec.biz.entity.app.AppVersionEntity;
import com.ctrip.ec.dal.DbAccess;
import org.springframework.stereotype.Service;

import java.sql.SQLException;

@Service
public class AppVersionDao extends DaoBase<AppVersionEntity> {
    public AppVersionDao() {
        super(AppVersionEntity.class);
    }
    public AppVersionDao(DbAccess db) {
        super(AppVersionEntity.class,db);
    }

    public AppVersionEntity latest(Integer type) throws SQLException {
        String sql = "select * from " +this.getTableName() + " where type=? order by id desc limit 1";
        AppVersionEntity entity = this.db.getScalar(AppVersionEntity.class,sql,type);
        return entity;
    }
}
